program LbmpService;

uses
  SysUtils,
  uDZProcess,
  Windows,
  uLBMPService in 'uLBMPService.pas',
  uAppConfig in 'uAppConfig.pas',
  uAppLog in 'uAppLog.pas',
  uAppCmdLineParams in 'uAppCmdLineParams.pas',
  uSockSvr in 'uSockSvr.pas',
  uLbmpPkgProcessor in 'uLbmpPkgProcessor.pas',
  uLBMPPackage in '..\common\uLBMPPackage.pas',
  uAppStatus in 'uAppStatus.pas',
  uGoogleMap in '..\common\uGoogleMap.pas';

{$R *.res}
{$R media.res}

var
  Service: TLBMPService;

function ConsoleCtrlHandler(Ctrl: DWORD): BOOL;
begin
  Service.Stop;
  Result := True;
end;

begin
  ReportMemoryLeaksOnShutdown := CmdLineParams.DebugMode;
  IsMultiThread := True;
  RandSeed := GetTickCount;
  Randomize;
  Service.Initialize;
  try
    if cmdLineParams.RunMode = pemNormal then
    begin
      Windows.AllocConsole;
      SetConsoleCtrlHandler(@ConsoleCtrlHandler, True);
      Service.Execute;
    end
    else begin
      Service.InstallAndRun;
    end;
  finally
    Service.Finalize;
  end;
end.
